On later cars: The secondary air system pumps clean air into the exhaust ports on start up to ignite any unburnt fuel and heat the cats up quicker. It’s controlled by the ecu, there’s a air pump in the front wheel arch and as you say two valves that fed into the exhaust ports via an oval inlet on each head
The valves are closed after initial cold start so exhaust gases can’t feed back into the pump (although that’s a common failure). It doesn’t do anything once warm, it only runs for 30-60secs.
It’s a common thing to delete on E46 BMWs, you just fit a blanking plate and code it out of the ECU.