If you have two curves of 4 data points each, the length of resid is 4, since each curve will create 1 residual value of each data point.
The point is that the number of data points (as reflected by resid) must exceed the number of estimated parameters, beta, in order for the parameters to be estimated uniquely and for the confidence intervals to have any meaningful interpretation.