Don't forget the maintenance costs and related expenses that Country B incurs. Not to mention that Country B has to guess the right amount of infrastructure to build.
The costs Country A incurs are plowed back into Country A's economy during the "building boom".
Don't know which country ends up better off, but there are many more variables than you imply.