Grand Prince Poutine Lord High Thrifter
Can I buy ships before there a wharf out?
Yes, buying ships is permitted, but building requires the wharf.
Also, if someone used my building can I sell the building and buy it again to use it right away?
No, because you cannot sell and buy the same building in the same turn. But you can sell the building (throwing your opponent out) and enter it on the same turn.