Compactness of L-weakly and M-weakly compact operators on Banach lattices