I'm pretty sure it has to do with it not getting to the delay before it's told to use another set of frames.
You can avoid it by doing a check to see if the current frame being shown is between the frames you want to switch it to... if it isn't then switch to the first frame of the new set.
REM Project: Elephant Game
REM Created: 11/21/2006 8:10:42 PM
REM
REM ***** Main Source File *****
REM
REM ***SET X AND Y VARIABLE
X = 512
Y = 300
REM ***SETUP A NAME FOR THE SPRITE***
#CONSTANT elephant 1
REM ***SET SCREEN RESOLUTION***
SET DISPLAY MODE 1024,768,32
REM ***LOAD ANIMATED SPRITE***
CREATE ANIMATED SPRITE elephant,"MATHEFANT.PNG",3,4,10
REM ***DISPLAY SPRITE***
SPRITE elephant,X,Y,1
DO
if leftkey() = 1
if sprite frame(elephant)<10 or sprite frame(elephant)>12
set sprite frame elephant,10
endif
PLAY SPRITE elephant,10,12,100
dec x,1
endif
if rightkey() = 1
if sprite frame(elephant)<4 or sprite frame(elephant)>6
set sprite frame elephant,4
endif
PLAY SPRITE elephant,4,6,100
inc x,1
endif
if upkey() = 1
if sprite frame(elephant)>3
set sprite frame elephant,1
endif
PLAY SPRITE elephant,1,3,100
dec y,1
endif
if downkey() = 1
if sprite frame(elephant)<7 or sprite frame(elephant)>9
set sprite frame elephant,7
endif
PLAY SPRITE elephant,7,9,100
inc y,1
endif
if x < 10 then x = 10
if x > 1000 then x = 1000
if y > 750 then y = 750
if y < 10 then y = 10
SPRITE elephant,X,Y,1
LOOP
REM ***END PROGRAM***
WAIT KEY
END