I think the reason they did the X was that when Model S was brand new they expected the market to 'max out' at ~20k vehicles a year (which wasn't unreasonable looking at other, similarly priced, niche premium brands).
So, they wanted a SUV to sell more cars. Now, as everyone (especially Tesla) knows, Model S has been selling very well. So in hindsight it was a big waste of time/resources. But I can see why the mistake was made.