A unit can enter and garrison an unoccupied building if it can move into base contact with the building during the Movement phase. Some units simply cannot enter buildings – the members of the regiment are just too big – unless differently specified, only infantry, war beasts and swarms can garrison a building. War machines can be deployed in buildings, but only if there is space to deploy the model on the top floor. Units cannot garrison a building in the same turn in which they have marched or made a reform.
When a unit garrisons a building, you'll normally find that there's not enough room for the models in or on the structure (or that placing them in the building just looks silly). It's perfectly acceptable to place a representative model from the unit in, on or next to the building to remind you that the unit is inside (standard bearers are the best for this!), and place the rest of the unit aside from the battlefield. The main thing you're trying to achieve is to leave a recognisable reminder as to the building's occupants for both you and your opponent as the game goes on.