It's fine to have both
https://example.com, though it's not preferred and it can cause some issues.
The major issue is duplicate content. Google won't know whether to index pages with www or without www unless you tell it what to do.
You can set your preferred URL version in search console to instruct Google to either index your pages with or without www.
Also, you should strongly look at either 301 redirecting one of the versions to the other, or using rel=canonical tags.
If you don't want the www. version, you can 301 redirect
https://example.com. Or vice versa. This will prevent your pages from being served under duplicate URLs.
If you can't 301 redirect the www duplication, you can set rel=canonical
https://example.com/page-name on all of your pages, especially the ones on the version of
https://www. This will tell Google which page to index and which one not to.
You should also try to make sure that you don't have any duplication issues with HTTP and HTTPS, though it seems that you have the proper redirects in order.
But you do need to address the duplication of both existing www and the nonexisting www URLs. Having both of them means that all of your URLs have duplications, and so you need to properly instruct Google to index the one you want.
301 redirects and rel=Canonical is how you address that.