Interesting point you make, as I see the dilemma . His and him, as opposed to only the word her. As a native speaker I never think of these small quandries , haha. The way to say it is to put it in context, meaning you need to add additional words to clarify your meaning. So,, You say I will buy her flowers, usually without otherwise stating, means you will buy flowers for her. Since that is the common use. You can also be very specific and say I will buy flowers for her. If, you wanted to state the other meaning you would have to say, I will buy flowers from her. Need to use , from. Or say I will buy the flowers she is selling.
--- Also, your sentence " "Buy flowers to him" " -- should be from him, not to him.