Guns aren't always directly comparable to cannons of other ratings, especially at lower ratings because there isn't a huge range of available values at those ratings. There are only 9 non-special ratings used in the game (1~9), and all item types use a separate scale for their base values, so comparing low-rating items across different types may find some unexpected overlaps like this.
Cannons are intended to be better than guns, as long as you can afford any additional costs they incur, and because cannons of rating X are better than guns of rating X, they may very well also be somewhat better than guns of rating X+1. (Beam Cannons are also much more rare than Beam Rifles, because the latter is commonly used by the enemy.)