Computer viruses

Sorry if I’m asking an off-topic question, but I really need some advice. I have connected to a computer with the windows remote desktop connection, could I get infected with viruses because of that and how I can avoid it? Thanks!

It depends on the infection vector of the virus. The virus can only spread if it is able to run code on your or vm pc.
Regarding RDP protocol itself, I do not know such a vulnerability. But if you use some other protocols, such as shared folders, SMB I think it is possible.