You can only prepare spells that you copied yourself
Can another wizard write into your spellbook?
First, can another wizard write a spell in a spellbook that is not theirs? Absolutely. A standard spellbook is described in the adventuring gear section of the PHB thusly:
Essential for wizards, a spellbook is a leather-bound tome with 100 blank vellum pages suitable for recording spells.
It is not a magic item: not only does it show up in the list of mundane adventuring gear, it also is not listed in the magic item section of the DMG. It is just a book1 of high quality, that you use expensive, special inks to write spells into. This unofficial Jeremy Crawford tweet confirms it.
So there is nothing stopping another wizard writing spells in "your" spellbook. You just bought the book on a bazaar. It does not mystically get bonded to you by that act. If you find a spell book of a rival mage that has blank pages, you can happily use it to write your own spells into it. (Although the rules do not specify how many pages your spells need).
Can you prepare spells they wrote?
However, that does not mean you can decipher their spells. As has been quoted in other answers, the sidebar "Your Spellbook" in the description of the wizard class (PHB, page 114) says you can copy spells that you find (e.g. on scrolls or in the spellbooks of other wizards) into your spellbook:
Copying [a] spell into your spellbook involves reproducing the basic form of the spell, then deciphering the unique system of notation used by the wizard who wrote it. You must practice the spell until you understand the sounds or gestures required, then transcribe it into your spellbook using your own notation.
For each level of the spell, the process takes 2 hours and costs 50 gp. The cost represents material components you expend as you experiment with the spell to master it, as well as the fine inks you need to record it. Once you have spent this time and money, you can prepare the spell just like your other spells.
This clearly states
You must transcribe the spell into your own notation (which costs time and money).
Only once you have done so, you can prepare the spell.
This is really the condition for one of "your" spells: it needs to be written down in your personal notation.2 Because of this, if another wizard scribbles his arcane mumbo-jumbo in their notation into your book, they might be able to prepare it from there, but for you they are just wasting your pages. You will be unable to prepare it until you have copied it onto new pages into your own notation. At that point, you can prepare the spell.
1 Although it does not have to be a book.
2 A simulacrum you made of yourself is using your personal notation, and you argue you could prepare the spells it copied into your book. Such a simulacrum, however, is not another wizard; it is an illusory duplicate of the same wizard.