If you can bill by the hour, you benefit from the customer figuring it out on the go, which will take longer, but also be better fitted (If you can make it work)
If your job fits in "I'll make your X twice as good" or "I'll implement this standard" bill by the project, so you don't get punished for being more efficient; if it fits in "we'll solve your software problems", bill by the hour and you'll be rich, because they won't run out of problems to throw at you
I've worked with (and for) consultants and we typically billed by the project for things with well-defined scope, work, and outputs. (Maybe a small business website, or PBX system.) But we billed by the hour for things that were unfamiliar territory for us and forced us to learn as we go. Like migrating a bunch of data from an ancient proprietary database to Postgres.