If there are any links to the non-www version of the URL from anywhere then it can result in the non-canonical URL being indexed.
Also check that you have:
the correct
rel="canonical"
link element in your pages (and/orLink
HTTP response header).the correct URL stated in your XML sitemaps, RSS feeds, etc.
the correct preference set in Google Search Console: www vs non-www
Now that I have the redirect to www in place, this is no longer problematic
Although you do still need to make sure you have no internal links to the non-canonical URL.