Re: How do they know...
...whether sites run a CMS or not? Many of my sites do but you would never know looking at the source code.
Really?
It's right there in the header:
<meta name="generator" content="WordPress 4.9.1" />
And there's usually a "Powered by Wordpress" down in the footer somewhere.
Even if you stripped those out, the entire structure of Wordpress belies it's core. It's not hard to look for URLs in the source pointing at directories with names like "/wp-includes/" or "/wp-content/" unless you've literally gone through the entirety of WP with a find-and-replace to strip out any "wp-" references (which will probably break updates and installed plugins).
Other CMSs will have their own directory structures and distinctive headers which will give away their core, unless they've undergone a ground-up refactoring - which 99.9% of installations won't.