Chances are, you're trying to place a manger or a barn into a pen like this:
Unfortunately, the small and long pens do not have quite enough space for barns or mangers, even though it might look like they do.
To place a barn or manger, you'll need an enclosure that is at least 8x8 fields (for reference, a piece of cropland is 2x2), then you'll be able to place the enclosure item: