It sounds like it could be one of a couple things. In the mame config menu, make sure the mouse/lightgun x and y inputs are set to the correct gun input. It may be that the aimtrack button is showing up in mame as joy 1, but the gun needs to be mouse 2. Select input menu, select mouse/lightgun x, and carefully move the gun in a horizontal line. If it registers more than one direction, try again. Repeat for y.
If you have check this or it isn't the problem, some lightgun games have their own service menus with calibration that is specific to the game. You can usually get to the menu by hitting F2 or something. Then you use something like 1P to move down the menu, and 2P to select.