The actual calculations are on the osu wiki, and freely available for anyone.
In short, the actual location of the misses is important. Score has 2 components to it, accuracy score (based entirely on the accuracy with which you hit the note) and a bonus score. It's more complicated than standard, but a quick explanation goes like this:
Half the actual score you get for a note is based on a "bonus score" value. The bonus score increases when you hit a 300 or 320/max/300g/rainbow. When you hit a 200 or lower. If you miss, the bonus score is reduced to 0. It takes 50 320s in a row or 100 300's in a row to max it out again. Since it grows from accurate hits so much slower than it drops from inaccurate hits, this means that a score with inaccurate hits spread out across the map will lose more score than a map where you hit everything 300s or 320s until a hard section where you make a bunch of mistakes.
It's very common to have scores with better accuracy end up being worth less points because of exactly where in the map you made those mistakes.