It is probably working as you told it to, but you did not tell it correctly...
You do not say how it is failing so I will guess and say that it always attempts to create the directory...
Code:
[ $? == 0 ] && echo "directory exits" || echo "no Directory";mkdir -p /amt
If you intend for the OR clause to echo then make the directory, that is not what you are telling it. The trailing ';' ends the logical && ... || statement and the mkdir always executes.
What you need is...
Code:
[ $? == 0 ] && echo "directory exits" || echo "no Directory" && $(mkdir -p /amt)
If that is not what you need, please tell us how it is not working for you.