A jar had the same number of green marbles and red marbles.

After a child took out 10 marbles, the remaining green marbles were 3 times the remaining red marbles.

How many red marbles were initially in the jar?
M = 3(M-10)

Solve for M

(This assumes they took out all red which your solution seems to assume.)

If they remove a mix of colors there are other solutions like 7 (remove 6 red and 4 green)
There are actually multiple solutions to this based on what you've told us

Since we don't know the combination of marbles taken out of the jar, we can set up a few scenarios

1) take out 0 green marbles and take out 10 red marbles

2) take out 1 green marble and take out 9 red marbles

...

10) take out 10 green marbles and take out 0 red marbles

Now, we know that the remaining green marbles is greater than the remaining red marbles AND that we started with the same green and red

So the number of red marbles taken out MUST be greater than the number of green marbles taken out, so you can eliminate all scenarios where you take out more green than red

The rest of the scenarios can then be evaluated using the fact that there are 3x as many green marbles as there are red by the end

Your answer seems to assume that you took out 10 red, but removing 4 green and 6 red is also a solution, as is starting with 5 of each color and removing all 10 marbles technically (since 3x0=0)

Edit: actually, now that I've sat down and thought about this, there is actually a viable solution if you take out anywhere from 0 to 5 green marbles