Difference of syntaxe between ui generated code and manually (regarding the doc) generated code


I would like to know why is there a difference in syntaxe between these 2 way to write code.
For example, try to make an automation or a script with the ui wizard, … and try to make one your self with exemple in the doc.
Both are functional, but code is not the same.
What i have already see is that if you call a service for example, if you didn’t put entity_id under a data, the result in ui wizard is bad, but your script is functionnaly ok

It’s not always easy to know which way is the best, i’m asking me what’s the main rules to choose the best way.