Well that is what can happen... in multi age groups.
5 year olds, are very different developmentally. BUT, many older kids... are also very empathetic with younger children. So... each kid being different. Not all 5 year olds, would react that way.
Over time though, teach your child about people/friends/niceness and that not all people/kids are nice. To have her own self-awareness... and just go play with someone else. It is not personal.
Or, speak to the Adult leader in that class. But, they can't force a 5 year old to play with a 3 year old.
Learning experience.... from this age on up... things like this can happen.