A combination of layoffs, lawsuits and AI operating costs set back Meta's Q2 earnings, despite increased revenue.