Constructing buildings next to your base is not instant if you build quickly. The game waits for the next tick to update which tiles are allowed to be built instantly. You can see this by slowing down the game and building a triangle next to your base; the building furthest away will be forced to fly from your base.