Organizing a team for Scrum development
When is it formed? Each sprint? Because in each sprint I may have
One of the key principles of Scrum is that you form a team that has all the skills needed to convert a product backlog item (PBI) into potentially shippable code. The team members are cross-functional and self-organize to accomplish whatever is needed to be done to deliver a finished product. It takes time for team members to build trust and gel as a team. So, you should plan to keep a team relatively stable for longer periods of time. This is the way to get high performing teams.
It's necessary to keep all members on development team, if only need
it for testing phase (e.g.: last week on sprint)?
Software development (or any knowledge work for that matter) is highly productive if handled by a skilled team that is highly motivated and allowed to focus on accomplishing one large business goal at a time. Such a team can often come up with better, faster and easier ways to solve the business problem. If you micromanage and think of it as tasks to be assigned to any free resource, you will get low productivity and an unhappy team.
A member can be allocated on different development teams, "at the same
Software development (or any knowledge work for that matter) is best accomplished by people who focus on one thing at a time without any distractions. Even within one team, Scrum Masters try to keep team members from working on too many stories at a time. So, the answer to your above question is, no you should not plan to have team members assigned to different teams "at the same time".
Having said that, sometimes I have compromised on this for practical reasons. We had a database developer who had specialized knowledge and skills about the back-end. I had him assigned to help more than one team at a time. However, I had other team members shadow and learn the ropes so that we don't have to continue this practice.