This doesn't have as much to do as chain length as it does resonance. The lone pair of the nitrogen in aniline can play into the conjugation, delocalizing it, and thus decreasing the basicity relative to methylamine.
Same thing for phenol - upon deprotonation, the anionic lone pair can play into the conjugation of the ring, delocalizing the charge, and thus increasing the stability of the conjugate base and thus increasing the acidity of phenol relative to methanol.