No, you normally don't need a separate hosting account. The issue is most likely related to the DNS record or domain configuration for the www hostname.
Your root domain (example.com) and www.example.com are treated as separate hostnames in DNS. Even though they belong to the same domain, configuring one doesn't automatically configure the other.
First, check whether you have a www DNS record.
A common configuration is:
Type: A
Name: @
Value: YOUR_SERVER_IP
Type: CNAME
Name: www
Value: example.com
You can also configure www as an A record pointing directly to the same server IP.
After updating DNS, make sure your hosting account recognizes both versions of the domain and that your SSL certificate covers both hostnames.
Finally, configure a permanent redirect so visitors are automatically redirected to your preferred version, either with www or without www.
This helps prevent visitors from experiencing different website behavior depending on which address they enter.