The Empire was formed after Napoleon's success in the wars of the Republican era, which occurred exactly because "A coalition of monarchies did gang up and wage war on the French republic".

Napoleon did not just emerge from the head of Zeus as a fully-formed Emporer.

And, technically, Napoleon headed the French government first while it was still nominally a Republic, under the Consulate of the Constitution of Year VIII.