Tell first why you want to use two timers for 2 PWMs. One N-Channel Timer can do N-PWM that are synchronized. Otherwise read the timer docs how to start timers synchronous.
You didn't tell us which STM32 are you using, but there are ample examples in the Cubes, e.g. for 'F446, [CubeF4]\Projects\STM32446E_EVAL\Examples\TIM\TIM_Synchronization , for yours you'll find it at a similar path, for one of the related devboards.