If you have a regular polygon with, say, 10 sides, and thus 10 corners, then going around the shape, you can draw from each corner 7 diagonals (because you can connect each corner to any other corner besides itself and its two neighbours). So going around the shape, you'd draw (10)(7) diagonals, but you'd draw each diagonal twice, once from either end. So a regular 10-sided shape has (10)(7)/2 diagonals, and a regular n-sided shape similarly has (n)(n-3)/2 diagonals.
So here, if we have one n-sided polygon, and one m-sided polygon, the sum of the diagonals will be (n)(n-3)/2 + (m)(m-3)/2, and if that equals 125, then
(n)(n-3) + (m)(m-3) = 250
I can see some number theoretic things one could do here, but none are especially elegant. I just did a quick estimate to see that the larger unknown can't be bigger than 17 here (then (n)(n-3) alone would be larger than 250). Then I guessed that the larger unknown is probably 15, since we'll often be adding two multiples of 5 if we're ending up with 250. That worked -- if n = 15 and m = 10, we get a sum of 250, and then n+m = 25.
I'd imagine there's a faster way to see that solution that I'm not spotting at a glance.