The way I understand it is Windows
optimizes a folder's view setting depending on the
type of files inside the folder rather than the the folder itself. Windows has 5 templates it uses for optimization; general items, documents, pictures, music videos. The user can change the default view setting of each of these these templates.
For example:
(All of my default folder view settings in file explorer options are set to default in control panel)
My
root Pictures folder is set to 'view as' medium icons.
My
root Documents folder is set to 'view as' details.
If I copy one of my sub-folders from pictures (Has 2 photos in it) to documents, that folder still opens as medium icons even though the rest of my folders in Documents open as details because windows determines the files inside the folder are pictures and uses the pictures optimization template.
If I add a document to that same folder, the folder will continue to open as medium icons because it has 2 pictures and a document in it.
However, if I delete one of the pictures, leaving only one picture and one document within the folder, the folder then views as details because Windows then uses its 'general items' optimazation setting to determine how its viewed.
The following article from theWindowsClub explains this far better than I could and shows you how you can change the default folder optimization setting Windows uses for each optimization template.
How to set a default Folder View for all folders in Windows 11/10