This study will look at how much CagriSema lowers blood sugar and body weight in people with type 2 diabetes. CagriSema is a new investigational medicine. Doctors cannot yet prescribe CagriSema. CagriSema will be compared to a medicine called tirzepatide. Doctors can prescribe tirzepatide in some countries. Participants will either receive CagriSema or tirzepatide. Which treatment the participant will receive is decided by chance. For each participant, the study will last for up to 1 year and 4 months.