Why are climbing shoes a slightly tighter than the regular mountaineering shoes?
Climbing shoes need to be extremely tight* because they frequently have to support a lot of weight on extremely tiny footholds, often on the tip of the toes:
Any free space inside the shoe could cause the shoe to deform (more) and slip off.
*: putting on the shoes should not be painful right away, but you can't get optimal performance with shoes that are comfortable to wear for hours and walk around in. It may of course be sensible to sacrifice some performance when you need to wear the shoes longer, e.g. on multipitch climbs.
Two reasons really
You want to be able to feel what your standing on, how you foot moves, is it gripping, etc. This also aids precision.
Compression allows you to put more weight though your toes
Try and stand on one toe without anything on your feet. Impossible right? Now this is the kind of thing climbers need to do all the time. So if you bind all the toes together (in a tight fitting shoe) then you can do this. This is because all the toes can work on one point at the same time.
press with your other hand on one finger upwards, you can't press very hard without it moving.
Now compress your fingers as though they are in tight fitting shoes: bend your fingers and press them together tightly:
now press on one finger, the weight is distributed though the other fingers and you can press a LOT harder.
Same principal with your feet. The sum is greater than it's individual parts.
I'll address the mountaineering viewpoint (as opposed to the other good answers about the climbing viewpoint).
Mountaineering usually involves covering a lot of distance over a bunch of different terrains: flat trails, scrambling/climbing, snow/ice, etc. A mountaineering boot thus needs to be able to do all of these in a single pair of boots, and be comfortable all day (or for multiple days). Not an easy task!
Mountaineering boots are designed to allow the climber to walk relatively comfortably, climb with some precision, and connect securely with crampons. Climbing shoes excel at climbing, but it's pretty much impossible to walk for long distances with them.
In the end, the amount of distance to cover will require a boot that fits well enough for walking, so the boot needs to fit closer to a street shoe than a climbing shoe.