it's great that you have so many questions. Keep them coming!
The European Union is collecting fingerprints of refugees that are older than 14 since 2003. It's a database for identifying asylum seekers and irregular border-crossers. It enables authorities to find out whether asylum seekers have already applied for asylum in another EU-member state or have illegally travelled through another EU-country.
The usual procedure is to take prints of all 10 fingers. I don't know why the Hungarian police only took two in your case.
There is 3 types of people whose fingerprints will be taken:
1) people that apply for asylum
The collected data of people that are seeking refuge will be checked against the existing database in order to find out if someone was registered in another EU-country before. This data will be deleted after 10 years. But it can happen earlier if said person becomes a citizen of an EU-member state.
2) people that try to cross an EU-border illegally
If a foreigner is getting caught crossing a border in the EU illegally, than his/her data will only be compared to all refugees that arrive after him. There will be no comparison to the existing database. Data that is collected this way will be deleted after 2 years.
3) people that stay in a EU-member state without applying for asylum
If a foreigner stays in a country illegally and gets caught, it's up to the responsible state to transfer the fingerprints to the database or not. If so, the data will be deleted after the results of the comparison are send out to other member states.
Is that the type of information you were looking for? Feel free to ask further questions if necessary. The community will do its best to provide answers for you!