In Rails, querying data starts by calling methods on a model like User. Methods such as where, order, and limit build a query object step-by-step without hitting the database immediately. This lazy building means no data is fetched until you explicitly ask for it, for example by calling to_a. At that point, Rails sends the SQL query to the database and returns the results as an array of records. Variables like 'users' hold the query object until execution. This approach helps build complex queries efficiently and only fetch data when needed.