1. You made a transcription error. Your code erroneously shows [ 2 2 2] whereas the figure is consistent with [ 2 10 2]
2. You made a conceptual error: The net creation statement does not include input and output dimensions. It only states number of nodes for each hidden layer. Therefore you have 5 layers, input, output and 3 hidden.
3. The number of nodes in the input and output layers are determined by the dimensions of the input and target vectors, respectively.
4. Remember the numbers in the creation statement are the number of nodes in each hidden layer, the number of numbers is the number of hidden layers.
Hope this helps.
Thank you for formally accepting my answer