"What can I do for you?", culturally, is an expression mostly used in transactions. As in, a store clerk will ask you this as you enter a store, or a customer service agent will ask this question when taking your call. For this reason, a native English speaker will think of it as cold, because it sounds very impersonal.
Also, it's often used as an ironic response to someone who is making you uncomfortable. For example, if someone in a bus stop or in a library keeps looking at you, you might turn to them and ask them "what can I do for you?", meaning to say "either be clear about your intentions with me, or stop what you are doing".
Either way, and this is a personal opinion, A's response is rude, considering they had no ground to believe B had any bad intentions.