While most essays are assigned, not all assignments are essays. Your math homework may include word problems, but you aren't likely to write an essay your math teacher will be interested in reading. The differences lie in the what is included under the individual definitions and who will be doing the assigning.
An essay is a written piece of work that analyzes or describes a particular topic. Essays traditionally include an introductory paragraph, three or more body paragraphs, and a conclusion. The purpose of an essay is to inform readers on a chosen subject, and that information can be written as a description, a narrative story, a well-reasoned argument, or just a presentation of facts. No matter what type of essay you write, you'll need to do at least some research and organize your thoughts before putting pen to paper or fingers to keyboard.
An assignment is any work you're asked to do and usually comes with a required structure and questions to answer. For a math assignment, those questions will usually be written in numbers and symbols in equation form that need to be solved. For an assignment in a science class, experiments and reports may be required. For an assignment that requires writing, you may need to write an essay, a thesis, a book report, or even a poem.
It is almost always a teacher or professor who assigns an essay, but you may be given an assignment at work, too. Work assignments will not usually include essays unless you're a writer by trade.
For example, a journalist is assigned news stories to research and write, although they usually won't submit their writing in essay form. A lawmaker may be assigned to specific committees and required to do certain types of work for those committees. A nurse working in a hospital is assigned patients and a teacher is assigned students to teach. Any work can be assigned, and only some of those assignments require essay writing.
The assignments you'll be given throughout both your academic and employment career should always be clarified by reviewing the specific requirements involved and asking questions of the assigner to ensure that you're meeting their expectations. Successfully completing any assignment takes some amount of work, but that work will be even more successful when you know what is expected of you.