If not, how can they know?
By examining the publicly viewable blockchain data. As I said above, coinjoin transactions are easy to identify.
For example, here is a recent JoinMarket coinjoin I just pulled from the blockchain:
https://mempool.space/tx/98423f23138446f079442bda7856b87cba075d15142ae756e06dcbdc0eb6b61cIt has all the characteristics of being a JoinMarket coinjoin which makes it easily identifiable - large number of inputs and outputs, similar number of inputs and outputs, all inputs are from segwit addresses, multiple outputs of identical values (0.04416277 BTC in this case) in order to obfuscate which is which, and if you look back in time the majority of the inputs have come from similar JoinMarket coinjoins.
Similarly, here is a recent Whirlpool coinjoin I just pulled:
https://mempool.space/tx/5a734035c9745820dc98ab79209a1e44d4fbd2b7a0ed1dd417131be31a7ad763These are even easier to identify, since Whirlpool uses fixed pool values of 0.001 BTC, 0.01 BTC, 0.05 BTC, or 0.5 BTC, they always have the same number of inputs and outputs, and two inputs will always be slightly more than the pool size in order to pay the transaction fee.
As I said, the privacy gain from coinjoin transactions comes from it being impossible to link the inputs to the outputs, not from the coinjoin transaction itself being hidden or secret. A blockchain analysis company can easily watch where all the outputs of every coinjoin transaction go, but if they don't know who owns those outputs, which other outputs that person controls, or who owns the addresses they are being sent to, then they can't do anything with information. But if a very small number of outputs all go the same unusual and identifiable place, which I imagine would the case when taking outputs from one coinjoin implementation and sending them to a second coinjoin implementation, then they can infer common ownership. (I have no data on this, I am just postulating that moving coins from one coinjoin implementation directly to a different coinjoin implementation is not a very common thing to do.)