Represent the number of dogs as x
Then, the number of cats is (x+2) x 2 = 2x + 4 (the number of dogs is two less than twice the number of cats -> the number of cats is 2 more than twice the amount of dogs)
There is a total of 25 animals -> 2x + 4 + x = 25
Simplify as 3x + 4 = 25
3x = 25 - 4 = 21
x = 21/3 = 7
So, there are 7 dogs, and 25-7 = 18 cats.