p if q, means if q happens then p happens. There CAN be cases where q doesn’t happen, but p happens. In other words, q is NOT the only condition that p happens.
p only if q, means q is the necessary (a must-have) condition that p happens. In other words, if q happens then p happens, AND if p does not happen then q does not happen. It implies that if p happens, then it must be that q is true (true is equivalent to "happens").
p if and only if q, means q is the necessary condition for p happen, AND p is the necessary condition for q to happen. More concisely, it is equivalent to "p only if q, AND q only if p".