Were foreign ambassadors typically stationed in other countries? Would they live in the King's castle? If not, then where?
I will speak mostly of the ambassador system in the Early Modern era.
Today's system of embassies, ambassadors, and diplomacy started to develop in Italy in the 14th-15th century. City states felt they needed a fast and reliable means to communicate with their allies and adversaries, and started to assign persons to represent their interest in other city states. They resided mostly in their own residence, and they make themselves available to the local ruler. They often spent time in the local ruler's place of power, be it a Palace or office or what not. Remember, at this point there were no rules. They were simply made available in place to facilitate communication, some degree of negotiation, and to update their employers on the goings-on at their places of assignment.
King Ferdinand of Aragon was credited with using this system to set up resident ambassadors to represent Aragon (and Spain) at Rome, Venice, London, Brussels, and the Austrian Habsburg court which was migratory. The ambassadors came from a wide range of backgrounds, but most had some degree of legal training.
The system was very much new, so there were challenges to overcome in terms of how to actually send correspondence reliably, how to keep track of them, how to keep other parties from snooping in, and even worse how to keep them paid. The ambassadors often had to pay out of their pocket and not be reimbursed until the end of their assignment when they could demand payment in person!
Over time, Ferdinand and Isabella started to develop a national postal system for the peninsula, with extensions abroad. Under their successors Charles V and Philip II, this system was so far more reliable than anybody else's, that the French ambassador in Spain preferred to use the Spanish system than to rely on the poorly maintained French network. He knew full well the Spaniards would read his letters, but preferred that his letters actually make it to Paris and be read rather than not!
Ambassadors in this period became part of the court of the king, and as before, make themselves generally available to the local rulers. As members of the king's court, they follow that court's protocol and system.
Rulers of this time had time slots for "audiences" so ambassadors would make an appearance and request an audience to discuss matters. Sometimes they took up too much of the ruler's time. As Philip II of Spain lamented in 1576, "[the Portuguese ambassador] was here and spoke to me for a long time, which made me waste the whole morning." A few days later he lamented, "‘the French ambassador and others have just been here, which has cost me the whole day." Indeed, he then wisely observed that, "audiences and paperwork just don’t go together."
Given the delays in communication, ambassadors had a wide degree in latitude in interpretation and negotiation, and different ambassadors had their own styles in reporting back to the home country.