What makes him an irresistible force in T20?
Legspinners have a distinct advantage over fingerspinners in being able to turn the ball either way without much changing the action or bending the arm. The fact that they can take the ball away from both left- and right-hand batsmen makes them successful in T20 because most big hits are through the on side, using the bottom hand, and legspinners make batsmen hit against the spin.
Leggies do have to change the way they deliver the ball while moving from bowling legspin to googlies. From 22 yards away you can usually see the back of the hand when the googly is bowled, and so can play accordingly. In Rashid Khan's case, it's almost impossible to differentiate between the two variations because you see the back of his hand even when he's bowling legspin. The only difference is the split-finger grip for legspin and joined fingers for a googly, but that's too difficult to spot. In addition, he has a quick-arm action that leads to higher bowling speeds, which in turn make stepping out a difficult option to employ. Such is the speed of his deliveries that some of the hittable balls go unpunished because batsmen don't have time to latch on to them.
Why didn't Rashid's methods work in the Test match?
The value of patience in Test cricket, for both batting and bowling, can never be overstated. The key to Rashid's success in T20, like for most other successful bowlers in the format, was not bowling two identical deliveries on the trot. The idea in the shortest format is to keep the batsman guessing by mixing it up almost every ball. In the first two sessions on the first day of the Test, Rashid did exactly that, and it didn't work.
In Tests, you need to focus on one stock delivery and use the variation only occasionally. The art of bowling six balls in an over in almost the same spot is the first requirement to succeed in Tests. It was only later on the first day that Rashid started bowling a lot of legspin deliveries and only few googlies. Also, bowling different variations too often makes it impossible to set the field, for unlike in T20 cricket, you need to pack one side in Tests and have few boundary riders.
Why the field placements did not work
Rashid has always bowled to a spread-out fields in T20 cricket, which meant that some good shots, and many relatively loose balls, only went for singles. It doesn't work like that in Test cricket, where every loose ball is put away for a boundary.
Since Rashid doesn't pause in his delivery stride, he has a tendency of bowling a little short once in a while, and these short balls are dispatched for boundaries in Tests because of the lack of protection in the deep.
Rashid and Afghanistan started with an overly attacking field, which resulted in a lot of runs being scored off him. His economy was over seven per over in the first session.
In addition to the loose balls and attacking field, the change in the batsmen's mindset also contributed to making him a slightly lesser force. In T20 cricket, the situation forces batsmen to make a move, and they are compelled to manufacture shots. Since time is not of the essence in Tests, batsmen are happy to wait for the bad ball to come their way, and that seemed to have forced Rashid to try a little too hard.
How the lack of first-class cricket hurt
The advantage of coming up the ranks in countries like India, Australia and England is that you usually have played about 40-50 first-class matches by the time you break into the national team. So you're well versed with the demands of playing the longer formats. It's one thing knowing that you need to bowl ball after ball at a similar spot for many overs at a stretch, but it can't be executed if you haven't done it many times over in the past.Afghanistan's first Test was only Rashid's fifth first-class game, and it was optimistic to expect him to acquire a new skill and muscle memory overnight.
While he did show considerable improvement as the match went on, it'll take a lot of cricket with the red ball before he becomes the same force in Test cricket as he is in T20.
Also, lots of people seem to be advising him to bowl slower to become more effective in Tests, but I wouldn't do that. His success doesn't depend on the speed at which he bowls but how consistently he bowls at one spot. He will also need to choose either the legspinner or the googly as his stock ball, and stick to using the other for variation only once in a while.
The art of setting up dismissals in Tests is quite different from that of setting up dismissals in T20. A few dot balls are enough to make the batsman jittery in T20, but in Tests, Rashid will need to master the art of boring batsmen with consistent and persistent line and length to induce mistakes.
He is a finished product in the shortest format but a work in progress in the longest.