opposing PID controllers
There are three common solutions to this:

Set the setpoints a bit apart.  Make the heater setpoint a little lower than the cooler setpoint.  These need to be far enough apart so that overshoot from one doesn't trigger the other.  If you can tolerate the resulting temperature range, this is the easiest thing to do if you already have existing separate heating and cooling systems.

Include a switch so that only one of the heater or cooler can be on at a time.  Some home thermostats are like that.  You generally know whether you need to cool or heat, so it's up to you to throw the switch appropriately when you want to switch over.

Use a single controller.  This is the architecturally obvious and best way to do it if you can design the overall system.  A single controller tries to maintain temperature, and it automatically switches between the heater and cooler as appropriate.  This kind of controller can even implement a break-before-make timeout during switchover and other fancy things.