Milan have done a really good job by taking advantage of Juventus' bad form recently. They are at the second position now after this. I find their productivity quite decent this season compared to their nearest opponents like Juventus and Bologna. The main problem is more related to Milan's defending. They have conceded 33 goals in 29 games.

They can actually solve this problem by transferring better defenders this summer. They spent 100 million+ euros in total for transfers last summer if I'm not wrong. They should focus on their defense line more next time they make transfers. If they conceded much less goals than this now they could have been in the title race.
It looks like Milan and AS Roma have the same goal total so far for results in Serie A but indeed, AS Roma conceded slightly more than Milan but the difference is only two goals. Therefore, it doesn't seem surprising that in the end AS Roma also has a chance to finish in the top four, and the appointment of De Rossi as head coach to replace Mourinho really has a good impact on AS Roma at the moment. But regarding Milan, I think they just need to focus first on finishing this season, because the transfer market will also happen for next season. Therefore, of course it would be more appropriate if Milan could improve their defense line for the rest of this season to be able to maintain their position in second place.