There's essentially two parts to your question:
What is WAL buffer and WAL segment file?
The WAL buffer is in memory and the WAL segment buffer is on disk. WAL buffer temporarily holds the transactions in memory till the point they are written on disk. If WAL buffer becomes full, the WAL segment buffer file comes in to play where all the WAL buffer is dumped.
Why are they required and their advantages?
This 2-step process helps us with two things:
- The performance is significantly improved because of the use of memory rather than disk as the later is much slower.
- Having a backup in the form of WAL segments files allows for crash recovery as transactions can be easily redone in case there's an issue.
It is important to note that while in normal use case we might not care much about these things but imagine a 100 transactions happening together, that is exactly when these little changes start to play a significant role. Hope this helps.