There are few better ways to learn something than to explain that thing to someone else. For example, pair programming is a key aspect of a new software design methodology known as Extreme programming. In each assignment I give, I do my best to make it clear whether the assignment is intended to be primarily collaborative or primarily individual. In my classes, I assign a variety of types of work. Different categories have different expectations.
Laboratories are almost always collaborative.
You should generally plan to work on laboratories with at least one other student. If I ask you to write up a laboratory, you and your partner should do one writeup. You should not copy text from another group's writeup. Homework assignments may be individualized or collaborative. However, you may certainly ask a colleague to proofread or comment on your answers.