I view freelancer as just a developer/engineer that is paid on invoice.
I view consultant as someone with specialized or advanced knowledge who can address the problem beyond writing some code. But they may still write some code. But they are hired for a specific purpose and issue not as a general developer.
And contractors will often do consulting in the beginning stages, e.g. if they're hired to "build a website", they might give the customer specialized advice on what to consider or prioritize, ...