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),
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.