Power Query Formatter is in Beta stadium, so don't expect it to work perfectly. If you encounter any issues please leave us a bug report so we can improve our service.
The formatter formats by trying to put as many statements as possible in single lines. Once the lines exceed the configured maximum line length the formatter forces the last most expression to break line. If the resulting layout still exceeds the line length the next expression will be forced to break line. The break line behavior is defined seperately for each expression. Some expressions - like e.g. Literals - cannot break line because it doesn't make sense. Other expressions always break line like the let-Expression. You can explore the options tab in the formatter to view the parameter set that the formatter supports.
There is also an Api that you can use to automatically format queries.
The formatter uses your browser database to save your configured options and your last query.