Why the function chooses the second case to execute?
Because you called the function with two inputs. MATLAB first checks the case 1 case but nargin is not equal to 1, so that case is skipped. Next it checks the case 2 case and since nargin is equal to 2, MATLAB executes the body of that case.
One key point to know, if you're familiar with other languages, is that cases in a switch / case do not "fall through". At most one case in a switch / case block will be executed.
What is the use of "otherwise"? I was assuming, when I pass 3 arguments (or no arguments), it would be considered as the "otherwise" case. But it's not.
The otherwise case would have been executed, if you called your function with 3 arguments and MATLAB had reached that point in your code. But the way you've defined your function:
function x = narginExample(y, z)
tells MATLAB that you will call this function with at most two input arguments. If you try to call it with 3, MATLAB has no "place" to assign that third input argument, and so it throws an error before even trying to execute any of the lines of code inside the function.
Calling this function with 0 input arguments would reach your otherwise case. Just because you've defined your function to accept one or more input arguments doesn't mean you have to call it with that many. You can call it with fewer.
You can write a function that accepts an arbitrary number of inputs, if you don't want to limit it by how many variable names you want to type in your function definition. To do that, use varargin as the last input argument in your function definition. That identifier is handled differently than any other identifier. See the "varargin and Declared Inputs" example on that documentation page. Even though the definition "looks like" it only accepts three inputs, because it accepts varargin you can call it with five inputs and any past the second get stored in the varargin cell array.