AI and data science work together by leveraging data to build models that enable machines to make predictions, automate tasks, and gain insights. Data science extracts and prepares data, while AI uses algorithms to analyze it, making decisions, and enhancing automation across various industries.