In answer to this question, it's interesting how they're different, and it might be helpful to give some insight into why they are different.
Levenmouth was a special case, for three reasons.
Firstly, the line was in railway ownership, the formation was intact, although in need of repairs, and there was an existing connection with the big railway. That's important because you don't have to negotiate with landowners, you don't need to do option sifting for an alignment, and you have a way of bringing materials in and out by train.
The cost of deciding which route to build, the costs of buying land, and taking the whole project through several levels of the legal process, is astronomical. You have to pay the salaries of every single person who is doing ground investigations or detailed design work, lawyers negotiating with landowners, and pay for the full legal process itself, for several years before you even put a spade in the ground.
Buying the land in St Andrews would be outrageous. The land owned by the golf courses and the university is some of the most expensive in Scotland, and although they would say that they are supportive, in reality, they'd be holding the line up with demands about where the line can go, and how much land they're willing to part with. This process itself would take at least a year.
In comparison, the Levenmouth line was open. It was unused, but it was still an open railway, legally speaking. Anything you do on the line is a permitted development, and all we needed was planning permission for the stations. By comparison, that was a walk in the park.
Secondly, the junction at the main line was there already. That's important because renewing the junction is a renewal, and the signalling interface with the main line already exists. It's much easier to build something 'offline' if it already has it's interface with the 'online' bit. All they had to do at Thornton was a renewal of the signalling and points, built the rest of the signalling on the branch, and plug it in on the end.
At Leuchars, by comparison, you'd be building an absolute minimum of three point ends, a new junction, and a new interface with the big railway. The reason that's a £60m one-off cost is that you're ripping out what's there already, and resignalling, putting something new in. A like for like replacement is easy, adding something onto the end of a branch line is middling, a full new junction, and all the resignalling that triggers, is very hard. What's to say that if you started messing around with the signalling at Leuchars, that wouldn't have to trigger a full resignalling; it might be covered by legacy rights, but that goes away as soon as you start putting new bits in.
Thirdly, the marginal cost of serving Levenmouth was very small. The Fife Circle timetable meant that the cost was an extra diagram and driver, because you can extend services that are already there. It was very obvious how you'd serve it, and you get a lot of value out of that.
St Andrews by comparison is a bit screwed. Either you serve it as a shuttle, which is paying for three or four extra drivers who basically sit doing a ten minute shuttle twice an hour, or you connect it in. As soon as you connect it in, then you start making journey times longer, or needing extra services, all of which costs a lot in ongoing operational expenditure.
The combination of these three makes it materially different, and not for the better. I've been trying to think of comparisons, and although there aren't any, I think the two closest are Devizes and Leigh. Both used to have lines, both served by a nearby 'parkway' esque station, both somewhat affluent, but both will forever be stuck without a station, because they're just too awkward to serve.