you have conflicting and/or redundant statements.
if neither A nor D is pressed, PlaySprite ( sprite, 0, 1, 1, 1 )
if A is pressed then PlaySprite (sprite, 21, 1, 2, 21 ) but if D is NOT pressed at the same time, PlaySprite ( sprite, 0, 1, 1, 1 )
ie, PlaySprite (sprite, 21, 1, 2, 21 ) will never happen since you later tell it to PlaySprite ( sprite, 0, 1, 1, 1 ) in the loop
then, if A is pressed, PlaySprite (sprite, 21, 1, 2, 21 ) but if D is also pressed, PlaySprite ( sprite, 23, 1, 1, 23 ) will occur since you told it to last
you're also telling (each) to start respective animation sequences from their first frame if a key is or isn't pressed, over and over. i can't remember but i don't think you'll ever see the second frame until a key is released (and/or NOT released...).
in the end, that's not the way to go about things. the logic "isn't"
an example of smoother transitions from one animation to another can be found
HERE.
it's using a virtual joystick and a little more advanced than what you're attempting to do but if you study the code you'll see a kind of "logic" that you should be applying where each
potential condition is properly accounted for. various "states", if you will.
you'll also pick up some other tips in that code which i think every newcomer should review so it's a good place to start for this kind of thing.
do study it, step by step. and follow where each state or condition leads you. there are a couple things going on at the same time so it's a good exercise IMHO.
meanwhile, welcome