Question about .available()

OK, can I get a good explanation of what the flush() does

Depends on which class implements the method, on which version of the IDE.

SoftwareSerial and Serial do very different things in the flush() method.

and when it is good to use it?

Almost never is my recommendation.

For the situation where flush() waits for the output buffer to be empty, there may be times when you want to wait until all data has been sent, so that you can time how long it takes to get a response. But, that's a pretty rare case, and the timing depends on too many factors to be reliable.

For the situations where flush() dumps random amounts of unread data, I can't think of a single case where NOT reading the data is appropriate.