It seems you might be misunderstanding what "for axis = [1; 0; 0]" does. A for loop like:
for axis = [1; 0; 0]
Will exceute the body of the loop with axis = 1, axis = 0, and axis = 0. You can run the code above to see that happening.
Therefore, in your code the input axis is being ignored, as all three for loops are being excuted (assigning new values for axis each time), leaving only the last execution of the last loop to set R.
Something closer to what you're aiming for might be (without any checking for input formatting):
function R = AxisAngle_to_Rot(axis, angle)
switch find(axis, 1)
R = [1 0 0; 0 cos(angle) -sin(angle); 0 sin(angle) cos(angle)];
R = [cos(angle) 0 sin(angle); 0 1 0; -sin(angle) 0 cos(angle)];
R = [cos(angle) -sin(angle) 0; sin(angle) cos(angle) 0; 0 0 1];
error('Invalid axis input');
find() gets the index of the axis being specified, and the switch statement picks which expression for R to use based on this.
I'd recommend reading the documentation for for, switch, and other basic elements of matlab to get a good grasp on how they work first.