The "would" implies a conditional and is thus, as already mentioned, more polite. E.g. the host offers you tea but you prefer coffee:
I would prefer coffee, (if that is possible/if you do not mind/if it does not trouble you)
You can of course still say "I prefer coffee" without the conditional, but it just isn't as polite. One could infact understand it as a rejection that comes very close to a "to hell with your tea, I only drink coffe".
As you noticed yourself "I prefer coffee to tea" seems very general. Nevertheless, another possibility to show the difference between both is the general expression:
I would prefer coffe over tea any time
Even thought it is not limited to the situation it has a conditional which implies that you are fine with tea if e.g. no coffee is available.
to your first example applies the same:
Shall we take a cab or walk home?
I would prefer to walk. (If it doesn't bother you, if you ask me, if my opinion counts)
These conditions are normally not phrased since it appears to be even politer not to mention them. Just one condition would reduce the effect, but naming multiple at the same time would be weird/overly polite.
"I would prefer coffee, if you got any (implies one does not care about the nuisance one might be for the other)"
"I would prefer coffee, if it isn't any trouble to you and if you have any. otherwise i am really fine with tea i am so sorry that I at all brought up my preferences."