Math - PhD or Master's + PhD?
I can't speak for purest math, but many parts of computer science overlap so I think there may be some similarity...

If you know that you want a Ph.D. and are able to get into a good Ph.D. program straight out of undergraduate, more power to you: this is a fine path to go on.  This may not, however, be possible or desirable for a number of reasons.  Some examples of good reasons to get a Master's at one institution before switching to another:


You might not get into grad school on the first try, and a Master's program is a good place to progress academically while you prepare to try again (this was one of my reasons)
The Master's is a natural break-point for transferring to a program that is stronger or a better fit.
Non-academic reasons, such as family issues, following a partner, visa problems, etc.