What exactly your question is about? How to keep sprites inside the tiled background? You can use BBox* expressions, for example:
Create Sprite at random(tiledbackground.BBoxLeft, tiledbackground.BBoxRight),
random(tiledbackground.BBoxTop, tiledbackground.BBoxBottom)
Sprite set animation frame to int(random(Sprite.AnimationFrameCount))
But if you are trying to make a grid map, I suggest using TileMap object instead.