Complex state tax situation

In this year (2021), I remotely worked in New York City throughout the year. But from 2021-01-01 to 2021-10-15, I lived in New Jersey; and from 2021-10-15~2021-12-31, I lived in California. So, in this case, how should I file state tax returns for this year? Will California or New Jersey tax all my income throughout the  year?

 

A separate question: As I just moved to California, I found both California and New York are withholding some taxes on my paycheck. But I heard I won't be double taxed. So, why both states are withholding tax on my paycheck?