Trebs inside castles

I have noticed that if you click the exit flag of your treb production on your castle so they will go inside.

But if your trebs are out, you cannot make them enter in your castle.

Is that normal or it’s a bug ?

That’s normal. Siege units can spawn inside buildings when created, but once you eject them they can’t go back inside.