It's simpler to say what an engineer does: this is a person who is responsible for implementing the technical aspects of the recording, mixing, and mastering processes. Engineers physically run the recording/mixing/mastering studios. By default and/or necessity it's also not unusual for engineers to have some input into the more artistic type of decisions, especially regarding sound, that are normally thought of as the province of the artist and the producer (and for which they often receive no public acknowledgement).
What a producer can do varies more widely, mostly depending on the type of music being recorded and the scope and budget of the sessions. Traditionally, the rough analogy with films goes something like this: record label = movie studio, label A&R (artist and repertiore) person = movie producer, and record producer = film director. This is a flawed analogy of course, not least because more often in music the 'actors' are also the writers and/or creative decision-makers as well as the performers. In practice the record producer's role can range anywhere from mostly an advisory role to the self-directed, creative artist, all the way to 'svengali' status where the 'artist' is basically just doing the producer's bidding, i.e. given material to record and told how to perform it. But in general, the producer can best be looked at as being either the 'musical director' or the 'sound director' of the recording sessions, or both, with the artist depending on the producer to help formulate and translate their intentions into a plan of action that is then carried out with the help and expertise of the engineers. Session producers don't always participate in the mixing and/or mastering processes (more often they do only with the former), but the final OK on many artistic and sound decisions, at least within the major-label context, often ulitmately comes from the A&R people in combination with the label heads. Of course when the producers and/or artists are bigger names, or even get their own label imprints, they get more say-so over the final product.