The cause of Marlow's shift in behaviors, from shy to lively, is not caused by a specific factor other than his particular penchant.
The comical baseline of the play would necessitate that someone, either the main character or someone close enough to him, experiences some sort of challenging issue that could infuse Shakespearean-style qualities that give place to either laughable behaviors, strange quirks, or strange ideas.
In Marlow's case his particular penchant is to prefer the company of women of lower social status than his own. When he is the presence of an equal, he seems to shut down and is unable to communicate openly. It is a species of phobia or anxiety. In the eyes of the reader, this phobia is correlated to the excessive importance that is given to social rules, social differentiation, principles, traditions, ancestry, lineage, reputation and the expected behaviors of the upper classes. This over-stimulation has saturated Marlow's mind to the point of shutting down even when he meets Kate Hardcastle for the first time.
MISS HARDCASTLE. You mean that in this hypocritical age there are few
that do not condemn in public what they practise in private, and think
they pay every debt to virtue when they praise it.
MARLOW. True, madam; those who have most virtue in their mouths, have
least of it in their bosoms.
So was Marlow, that even Kate herself admits that he hardly even looked at her. This is evidenced by the fact that, when Kate poses as a maid to elicit Marlow's better part of himself, he was unable to recognize that the maid is none other than Kate herself.
Therefore, it is the dichotomy between your true self and the person society wants you to be that makes Marlow so uncomfortable to be himself.