They sometimes find out when they ask you. If you are suddenly not available as needed for either job,'they might start to wonder why and ask about it.
Unless there is some association between the two companies, they may very well never know of the other. But, some people talk a bit too much around the water cooler and before you know it, somebody has told the boss.

