For shipyard rush buys you are charged for the cost of the remaining production to finish the project. You see different prices because there is already production made towards the shipyard when you made the purchase. This happens without the user noticing due to one of two dominate factors - you are using a planet you conquered but had not yet built anything in the shipyard (the enemies production carries over to your project) or you used the governor to stop building all ships of whatever type.
You can see this with ease by rush buying projects that already have production devoted to them i.e halfway through building a colony ship you see an economic resource! So you change what the shipyard is building to a constructor and purchase immediately. This constructor purchase will be cheaper because you are paying for the remaining production required. On the next turn the purchase cost will be full price.
You see ships that cost nothing because more production than the purchased project requires has already been "gathered" in the shipyard. Example - the enemy was nearly finished building a colony ship and you rush bought a scout.
You see this exact same thing with your planetary improvements. You are purchasing the remaining production required.
Purchase costs do not increase with successive purchases.
The straight purchase cost was figured out by Sole Soul - "Rush buy cost = (base cost ^ 1.1) * 6. Of course, one needs to keep in mind that (base cost ^ 1.1) is truncated, as are 99% of the things in this game."
For a good explanation of the purchase price mechanics - https://forums.galciv2.com/301696
Forum searches have helped me out a lot too. Some of these players love figuring out the mathematical foundations of the game.