Looking for a word that means "doing something only because someone else wants it." For example, i am getting a chocolate birthday cake only because everyone else likes chocolate even though I wanted vanilla.
I think you are describing altruistic behaviour.
If you are looking for a word to drop into that example sentence then I must admit that is quite difficult. I don't think it's a normal use of the the word altruistic when referring to yourself.
For instance you might describe a third person as altruistic or indeed selfless.
George selflessly cooked a fish dish for his friend even though he personally hated fishy food.
I would suggest indulgent, however this does not mean that you are acting against your own interests (though it does imply that your interests are not considered), only that you are obliging others.
i am getting a chocolate birthday cake to indulge everyone else even though I wanted vanilla.
Although oblige (To do a service or favour) might work better:
i am getting a chocolate birthday cake to oblige everyone else even though I wanted vanilla.
For you to get "a chocolate birthday cake only because everyone else likes chocolate even though . . . [you] wanted vanilla" indicates deferential behavior.
The word deference carries with it the concept of submission to the will of another (or others). The reason for the deference might be the "superior" rank of the person to whom you are deferring, or as in the case of the chocolate cake the reason may be to submit to "the will of the people."