Most professionals ought to charge by the project, because it’s a project the customer wants, not an hour.
Surgery, for example. I don’t want it to last a long time, I just want it to work. Same with a logo or website design.
Charging by the hour protects the professional. Charging by the project sets expectations up front and is a much better way to align both parties.