You have to treat LLMs like any other developer that you'd delegate work to and provide them with a well thought out specification of the feature they're building or enough details about how to reproduce a bug for them to diagnose and fix it. If you want their code to conform to the style you prefer then you have to give them a style guide and examples or provide a linter and code formatter and let them know how to run it.
They're getting better at making up for these human deficits as more and more of these common failure cases are recorded but you can get much better output now by simply putting some thought into how you use them.