It's cute.
I hope to find out wether the game has interesting mathematical properties and wether it's a balanced game if you play it on certain grids.
Not sure you mean by balanced. If players can look arbitrarily many moves ahead, there will always be one player who can guarantee a win. Which player this is might depend on the starting position. This applies to lots of games, including Chess and Go; these games are still interesting to play because in practise we can't look far enough ahead. But this game is weaker than those because it's easier to look ahead - a player has at most three possible moves to choose from (four on the first turn). You can counteract this by playing on a really large grid, so you have to look many moves ahead, so there are still many possibilities to consider.
You can solve it completely on some very small grids.
2*2 - First player wins. (In this case, it doesn't actually matter what moves you do - there's no way to get a different outcome.)
2*3 - First player wins. But if X is in a corner, it's possible for second player to win if first player makes a wrong move.
3*3 - Second player wins if X is in a corner or the centre, first wins if X is on an edge. First player can win if X is in a corner, if second player makes a wrong move.
Feels like first player should have an advantage if the number of dots is even, and second player if odd, just because that means the maximum number of moves in a game is odd/even respectively.
As for mathematical properties,
any game like this is equivalent to a Nim position.
edit: Hadn't noticed that you're letting first-player choose the starting position. That gives them a huge advantage, which I suspect will let them win every time (assuming no mistakes are made). That is a weakness.