Yes, it is possible to see both gorillas and chimpanzees in 4 days in Uganda.
If you start from Kampala or Entebbe, your first day will mostly be spent driving. It takes around 10 hours to reach Bwindi or Mgahinga in the southwest. On day 2, you go gorilla trekking in one of these parks. This is the main highlight of the trip.
After that, you can continue to a chimp trekking location. This may happen in the afternoon of day 2 or the next morning, depending on your route. Good chimp trekking options include Kalinzu Forest Reserve or Kyambura Gorge.
Both are close to Queen Elizabeth National Park. This also gives you a chance to enjoy a boat safari or game drive in Queen Elizabeth. Here you can see elephants, buffalo, hippos, lions, and sometimes leopards.
Even though this itinerary is possible in 4 days, it feels quite rushed. Many travellers prefer 5 or 6 days for a more relaxed experience.
Some safari routes also start in Kigali, Rwanda. This is closer to Bwindi and Mgahinga, with much shorter driving times compared to Kampala or Entebbe. It is also worth noting that gorilla permits in Rwanda cost US$1,500, while in Uganda they cost US$800.
So the choice often depends on time, budget, and how fast you want to travel.