The special features for this explain a lot. After Merantau the team had this big epic crime movie planned called Berandal, but they couldn't get the budget. So th director started work on The Raid because they could do it on a much lower budget. After that was a huge success they went back to Berandal and rewrote it as a sequel to The Raid.
Which is why it's 2 and a half hours long. All the gang war stuff was already in the script, and they added the undercover cop stuff for Rama on top of that.