can a function be both linear and nonlinear
No, it cannot. It can be either or.
No. a function can only be linear if it follows the formula y=mx+b