In both of the examples you show, the code's author wanted the second output from FINDPEAKS, and so ignored the first output using the tilde. What outputs a function has is explained by its documentation.
"I know that find peaks returns two arguments x and y axis of peak"
The findpeaks documentation actually says that its first two outputs are:
"pks ... a vector with the local maxima (peaks) of the input signal vector, data."