Does PostgreSQL write first to WAL and then to data files?
Your understanding is not correct.


  Specifies whether transaction commit will wait for WAL records to be
  written to disk before the command returns a "success" indication to
  the client


means that the transaction will be marked as committed without waiting for the success message.  This may come somewhat later (usually the time difference is very-very small), do to some magic done by the storage (caching, for example).  This means that you issue the COMMIT;, then the WAL data is written to the cache and only after this written actually to the disk.  Writing to the data files may happen later, but your data have been persisted at this point. 

Depending on the type of the cache and other things, there is a short time window with synchronous_commit = off when you may lose data if power is lost, for example.