How the detector finds a theme
WordPress keeps every theme in /wp-content/themes/ and every plugin in /wp-content/plugins/, and a page links to stylesheets, scripts and images inside those folders. The detector reads the folder names from the page's HTML.
A folder name is not always the theme's name, so the detector also opens the theme's style.css. WordPress requires that file to start with a header that lists the theme name, version and author, and the parent theme when it is a child theme.
Why some plugins don't show up
A plugin is visible from outside only when it loads a file on the page you checked. Contact forms, sliders, SEO and cookie plugins usually do. Backup, security, caching and admin plugins mostly work on the server and leave nothing in the HTML.
Plugins also load on some pages and not others, so a shop page lists WooCommerce add-ons that the home page doesn't. Check two or three pages for a fuller picture.
The theme is only part of the look
Most professional sites use a starter theme or a page builder and a custom design on top. Installing the same theme gives you its layout options, not the site you saw. The page builder and plugin list tell you more about how the site was built than the theme name does.