First, there are a huge number of possibilities as the US, at least, doesn't have a national system for higher education or nomenclature. In some labs a Research Assistant might just be a low level hire in a scientific lab who isn't involved in the educational part of the system at all.
But a frequently used distinction is that between Teaching Assistants and Research Assistants who are (usually) doctoral students and the position constitutes their funding. TAs are normally funded by departments and also normally continue for the time the student remains a student (until graduation). An RA may be funded the same way, but is also likely to be funded by grants received by individual professors (PIs) or research groups. The funding may not last for the entire term that the student remains and so they may also spend time as a TA. That might also be required by local rules as some teaching is considered advantageous to future academics.
But in the main, an RA will, as you suggest, perform research oriented duties under the direction (perhaps indirect) of a PI. The tasks may or may not be related to the doctoral research of the student. They fund the student, but the tasks are for the research group. But they give an opportunity to learn lab process in some fields.
Given that most incoming doctoral students in US have only a bachelors and need to pass qualifying exams after taking advanced courses, an RA held by an incoming student isn't especially likely to be directly related to the student's research, though it might be, and it might lead to a doctoral research project later.
For some students who enter with a bachelors they might start out as a TA, assisting in teaching the undergraduate program, and later, when they are ready to start serious researc
I don't know if the situation is the same in Canada.