I understand that the head of the penis must be covered at all times, but is it a risk if the shaft touched vagina or anus?
Thats correct,the head of the penis must be covered at all times.
One more question.
It's the tip of the penis that has to be covered at all times. If any part of the shaft was exposed to vaginal or anal intercourse, is that a risk?
As long as the condom did not fail you were never at risk.
If it didn't break then you never had a risk and an expired condom is likely to have become weaker.Make sure you always check the date on a condom.All the best.