If you buy a spool and the filament is tangling, then it is in 99.9% of all cases your fault.
You must not (never ever) let got the end of the filament. If so it may look like you got it without any harm, but once it escaped, it got tangled in most cases. The end digs in and it will resurface after causing a knot.
Rule #1 is to always fixate the filament roll end. Use the holes in the spool to lock it in. Use a clamp to fixate it to the spool.
If the filament breaks for some reason you cannot prevent tangling unless you guide it directly next to the spool through a ptfe pipe.
If the end escaped for some reason, get some tape and tape the entire spool down. Now unwind the end at least 10m, before you rewind it. The tape will prevent the section, where the filament end got below the filament on the spool, from moving further in. Filament knots are nasty.
You may loose the end on a new spool, but the knot may move undetected for hours and even prints. Retracts are loosen the filament on the spool and the knot can move further. But in the end a print will fail as some point.
It is a myth that filament gets tangled, when the spool got winded unevenly. That is impossible. The filament gets produced in one go onto your spool, so it is impossible to get tangled. The only way this is happening at the factory, when the worker is removing the filament and the end got loose. This should never happen, as the worker knows the problem and the spool gets fixed by quality control or sold as “b-ware”. So gettng a tangled spool from the factory is highly unlikely, unless the end was already loose in the package.
Just take a spool of sewing yarn as an example. There is no way you can tangle it up, unless you let the yarn end go loose. Since those spools are small and the material soft this happens only sometimes, but it happens in the same way as with filament.
There is no way a printer can tangle filament on its own.