If I make a software that generates code like a website creator can I automatically assign a lisence to it with copyright held by some person?Basically can a software generate code and then lisence it to someone under MIT lisence?
Only the copyright holder can issue a license. So the question would be whether you are a copyright holder of the generated code.
You are not a copyright holder just because your software generated some code. Instead, there would have to be your creative elements in the generated code, for example if copyrightable code snippets you wrote were copied into the output. Detailed criteria on what is and isn't copyrightable would depend on jurisdiction.
You should also consider that there could be multiple copyright holders involved, e.g. you for your snippet but also the generator's user for the user's snippets. You cannot claim copyright for the user's parts.
Normally, code generators want the generated code to be used as freely as possible. They would typically offer such code snippets under very liberal licenses, possibly requiring no attribution. This problem doesn't just exist for website generators, but also for compilers or parser generators. The MIT license might not be ideal because it requires the license notice to be preserved.
For a website generator that is not intended to be part of the open source community, an alternative could be to use contract law to require some attribution to remain on the website, such as a “made with SomeGenerator” link in the footer. While open source licenses generally require copyright notices to be preserved, they are generally unsuitable for requiring advertisements to be preserved. But all of this depends on the goals of the website generator.