Hi Jone,
The code seems to be working fine. Please ensure that you have saved the file with the same name as that of your function. If you are still facing an issue, try to change the name of the function because square function is an inbuilt function in MATLAB and there might be conflict. Do make sure that the file name and function name is the same.
Hope this helps!