When you want a favour from some one, you ask them like you want a favour and you should be prepared to be refused the favour. Your approach was not only demanding a favour with a question mark, but also followed that up with simply taking action you had absolutely no right to take, without getting a response, thereby also making your question a waste of time.
Turning off the tap without saying anything before or after would be less rude. Even stating "I'm going to turn off your tap because I can't stand wasting water like that" would be more genuine and more polite than what you did. The reason for this is in the fact that you asked a question you had no intention of hearing the answer to, yet in asking the question you partially acknowledged that you know you had no right to take the action, then did it anyway. Had you not asked anything, you would still be wrong, but at least it wouldn't be obvious that you were on some level aware that what you were doing was wrong.
An actually polite form would be:
"Could you maybe turn off the tap to when you're not using it to save water?" add in something about your feelings if you want to manipulate the person a bit, generally people don't want to hurt others feelings if it can be easily avoided.
After this you leave the matter alone if ignored or denied. In this situation, if you get an answer like "in a moment", or lack of immediate action, then don't take it upon yourself to turn the tap off either. You have no right to do this. At most you ask if you can. However this is a bit odd so you probably should explain yourself also.
His comment (about there being no water shortage) was his way of showing you that he thought you totally overreacted and were in the wrong, that your action was not in any way justifiable, since leaving the tap on is a non issue.
Even at this point, you could have still salvaged it all:
Simply realise that what you've done is wrong and inappropriate and apologise.
Maybe you could get away without an apology, just an acknowledgement that you were in the wrong, but without trying to justify the unjustifiable e.g. something like "i overreacted a bit, i'm just really concerned about..." (note "I'm really concerned about..." at this point and in this context, is an explanation of your actions after acknowledgement that your actions were wrong, not a justification)
Whereas something like you said "...doesn't matter..." = I don't care about your opinion or view, I am not going to acknowledge or even consider that I might have done something wrong "...you shouldn't waste water like this..." = instead I am going to teach and lecture you by stating what you shouldn't do (just by stating my personal views as absolute fact, and without addressing your earlier point.
The only time this is arguably a justifiable way to act is with your own child. While they are a still a child, preferably not in-front of other people.
The illustration of what his actions and words look like to most people (note they are not understood this way by most people, they are understood more emotionally and intuitively) are there to help him actually see how and why his words and actions appear the way they do to others in situations like this. This is because in his question at the end he states the purpose of the question "so I can prevent such situations in the future" and I believe it is important to fully understand the situation to prevent it, and similar situations, in the future.
The fact that you can't come up with an idea for how you could have handled this differently (i.e. your natural and normal response was to handle the situation the way you did), that you weren't instantly aware what you did was wrong as soon as you turned off the tap (or were aware but chose to ignore this fact) suggest there are some serious underlying issues that you need help with, I would suggest that you seek some kind of help if you want to improve your career prospects and general social interactions.