Why is it possible to flip the screen?

One common case where you'd want to turn your screen upside down is if you have a laptop doubling as a tablet computer, like this:

Leonovo Yoga in tablet mode

Another common case is if you attach a projector to the ceiling instead of letting it stand on a table, or using a rotated (and thus portrait) monitor.

Addressing the sideways rotation part of the question, the main time I've done so is when I've wanted to see many lines of content at once, e.g. a long file of code, a terminal output, or a spreadsheet. Some desktop monitors (e.g. this one) have a stand that rotates by 90°, but the software needs to rotate the video output too, otherwise everything becomes harder to read.

One can envision a circumstance in which the display mounting and associated brackets can only permit an inverted attachment of the panel. A kiosk with limited access may be one example, a display unit mounted at ceiling height with a mounting bracket that cannot be attached unless upside down.

In the case of a laptop, I can picture a situation in which the keyboard is mounted inside a box with the display extending outside the enclosure which would require to invert the image for viewing in a normal orientation.

I expect there are other circumstances in which this applies.