This game is actually equivalent to Tic Tac Toe. Each bag is a position on the grid, and each candy is a row.
For example, the following game:
is the same as the following Tic Tac Toe game:
So if you know how to play Tic Tac Toe, you know how to play this game too!