What was he doing in Iraq? Was he there on an official visit i-e guest of the Iraqi government or a clandestine / unofficial visit to just meet with the shia militias?
He has ties to both the government and militias and it is not uncommon for him to be in Iraq. Mostly likely scenario is they were discussing a coup against the Iraqi government and I don't believe they were preparing to attack US targets. They are too afraid to go that route.
Now we see fruits of US deployments to the Mideast over the past several months since the oil tanker hits. It was not a defensive posture and looks more like US is going on offensive against Iran and its allies and is now prepared for it. Even if Iran doesn't respond I expect another US strike either in Iraq or elsewhere against Iranian allies and it appears US wants war and will hit Iran's infrastructure.
The issue is that the US does not do well planning long term or dealing with aftermath of such situation. If for example they drag into Gaza into this and start attacking Gaza they will anger the whole Sunni world and destabilize Egypt/Libya. I think even Trump was misled and this was more a policy pushed and executed by the US establishment/Pentagon. Lots of American Jews within the ranks of the US gov't and they want US to go to war against Iranian allies, and especially against Gaza.
I don't think Trump understands that Qasem was a high ranking figure of a nation state and was instead fed information by his advisers and those around him(many Jews) trying to draw parallels between and Baghdadi for example. So he may believe he took out an AQ like leader but this is not the case. Iran operates more like a state and it does have state like oppression against Syrians and Iraqi's but you can't frame anyone and everyone as someone similar to Baghdadi just for character assassination sake and to justify war against them.
More leaders in the future in the region will be framed this way as well wrongfully.