Now, I understand that royal families wanted to have their children marry someone else of royal blood, and to also solidify an alliance through marriage. However, having a foreign spouse also had several potential downsides such as:
Considering these, wouldn’t it have been safer if the royal families had just married with the nobles in their own kingdoms?
While marrying local nobility wasn't unheard of, there were three main reasons medieval royal families generally preferred to marry abroad.
The case of Alexandra Feodorova is a bit different as, while she was a foreign princess, Russian monarchs hadn't married internally for a very long time. Alexandra's primary problem was that people found her cold and unapproachable, and the fact that she was German only came into play once she 'failed' in her duties as empress. Her predecessor Maria was incredibly popular, and you'll notice that very few (if any) people had an issue with her being Danish.
A good example of the dangers of marrying local nobility is the marriage of Edward IV and Elizabeth Woodville. Elizabeth had a lot of siblings—many of her sisters going on to marry far above what would have been their usual station and there was some concern that Edward would grant court positions to her brothers and sons from her first marriage. It also caused a feud between the Woodvilles and the powerful Neville family, culminating in a rebellion in 1469 which led to the execution of Elizabeth's father and one of her Grey sons. This then led to another Lancastrian rebellion, and on and on it went until we ended up with Henry Tudor on the throne.
If Edward had married a relative of the French king, as had been originally planned, it's entirely possible that none of this would have happened and the York dynasty might have spanned another hundred years or more.
So, in conclusion, that's why it was usually a better idea for a medieval king to marry abroad than to marry within his own country.