I can't think of any reason that the Babylonians couldn't have made gunpowder, had a time-traveller given them the recipe. However, there isn't any obvious reason for mixing sulphur, charcoal and saltpeter and then setting the mixture on fire. We don't know why someone in China did just that. Was gunpowder an incredibly unlikely invention, or did history get delayed several milennia by our unaccountable failure to invent it sooner?
Canons as we know them require a certain level of metallurgical expertise. We know from history that early canons were extremely dangerous to the people firing them. and to anyone neaby. Barrels often burst.
Here's a question. Can you make a crude canon with a wooden barrel instead of a cast-metal one? Obviously, not wood alone. It would split along the grain when fired. But what if you wrapped it tightly with hemp rope, or shrank iron bands onto it as coopers do with barrels, or laminated thin strips of boiled wood around a cylindrical form? (There are ancient composite bows; the idea of plywood is not recent). Then most of the charge should propel the ball, at least the first time it was fired. How many shots could such a barrel survive? How great a charge? It's crying out for a bit of alt-historical research.
If I'm guessing right, there's a place in the multiverse where Babylon had canons.