Adding a (stair/baby) gate without facing walls
They make a variety of gates for just this kind of thing.  They typically have 3 segments with adjustable angles.

For example at Amazon:



That middle segment is the normal gate, but the whole thing can swing/fold if needed.