No one would actually use this in production code. It is a useful convention for examples so that you can tell you are in server or client code. Occasionally it might be useful in a function that only has a slight deviation in behavior on the server, although usually you would wrap that difference in a function that is implemented separately in client or server only libraries.
In application code you would put all server-only code in the server directory and that code is excluded from the client code, same for client only code. In plugins, you specify which files are included in the client and server explicitly.
This is just one (basic) way to do this. In a real app you put all of your server code in a /server directory, removing the need for the if statements.