The infinitives give the purpose of the studying, and and can be paraphrased with "in order to"
I studied [in order] to be a doctor.
I studied [in order] to pass the test.
The infinitive phrases are not the object of the verb "study" but form an adverbial modifier. Above the object is implied, but you could give a noun as the object.
I studied calculus to past the test.
On the other hand the gerund form is the object and tells us what you are studing:
I studied being a doctor (I investigated what life is like for doctors, slighly odd)
Other examples sound odd because you don't "study", you "practise" or "learn"
I studied playing the piano (I investigated how a pianist plays)
I practised playing the piano
But there is no reason that you can't use a gerund, but it is unusual to study a verbal action, normally you study a subject at school, or a thing.
For my PhD, I studied rodents making nests.
I think your confusing might come from a slightly different meaning of the word "study" in Engish and your language. In English it means "to investigate in detail" or "Acquire knowledge of a particular subject". So "study playing the piano" doesn't mean "learn to play the piano" but it means "investigate the playing action in detail."