If Sam or Alex had 1 or 10, then they would have solved it straight away. But neither did.
But when Alex discovered that Sam didn't know, he went from not knowing to knowing. So Alex must have had a number where Sam's answer was crucial.
If Alex had 2, then Sam could have 1 or 3 - and the crucial answer "I don't know your number, either" would have ruled out 1, leaving 3 as the other number (Solution: 2 and 3)
Now, if Alex had 3, then he would expect Sam to have either 2 or 4. But if Sam had 2, Sam could have guessed the answer already (because Alex had already said he didn't know, so could not have had 1). When Alex discovers that Sam also doesn't know, he can rule out 2 as the answer. (Solution: 3 and 4).
Exactly the same arguments work at the other end of the range, providing the other two solutions: (Solution: 9 and 8) and (Solution: 8 and 7)
But when Alex discovered that Sam didn't know, he went from not knowing to knowing. So Alex must have had a number where Sam's answer was crucial.
If Alex had 2, then Sam could have 1 or 3 - and the crucial answer "I don't know your number, either" would have ruled out 1, leaving 3 as the other number (Solution: 2 and 3)
Now, if Alex had 3, then he would expect Sam to have either 2 or 4. But if Sam had 2, Sam could have guessed the answer already (because Alex had already said he didn't know, so could not have had 1). When Alex discovers that Sam also doesn't know, he can rule out 2 as the answer. (Solution: 3 and 4).
Exactly the same arguments work at the other end of the range, providing the other two solutions: (Solution: 9 and 8) and (Solution: 8 and 7)