Yes you can. You can buy a resource any time you could use it.
And you must use the resource in your turn.
You can purchase a resource in the market if:
-it is available in the market (i.e. there is at least the the 3 money slot empty)
- you don't have that resource available on one of your tiles
- you must use the resource in the process of purchasing a tile.