The Player's Handbook on Spells Copied from Another’s Spellbook or a Scroll says
A wizard can also add a spell to her book whenever she encounters one on a magic scroll or in another wizard’s spellbook.… [T]he wizard must first decipher the magical writing…. Next, she must spend a day studying the spell. At the end of the day, she must make a Spellcraft check (DC 15 + spell’s level).… If the check succeeds, the wizard understands the spell and can copy it into her spellbook…. (179)
(Link mine.) So, by the core rules, a wizard can copy any written spell into her spellbook.
However, the Rule's Compendium says, "Spellcasters who use spellbooks can add a spell to their book whenever they find one on a scroll or in another caster’s spellbook. The spell to be copied must be on the copier’s class spell list" (160), and, here, the Rules Compendium agrees with one of the game's designers (see this answer). Ask your DM. This DM has found the game easier to manage for both the DM and the wizard if everyone agrees to limit wizards to scribing into spellbooks only spells that are on the sorcerer/wizard spells list, but another DM's experience may be different.
A typical single-classed wizard can't cast spells that don't appear on the sorcerer/wizard spell list even if they are in the wizard's spellbook
The presence of a spell in a wizard's spellbook doesn't enable that wizard to cast that spell.
The Player's Handbook in the description of the wizard class feature spells says, "A wizard casts arcane spells (the same type of spells available to sorcerers and bards), which are drawn from the sorcerer/wizard spell list…" (56). For example, the typical single-classed wizard just can't cast a spell that's exclusive to the cleric spell list even if the wizard understands that cleric-spell-list-only spell and has it in her spellbook.
In short, a spell must be on the sorcerer/wizard spell list for a wizard to cast it. Alternatively, an individual wizard must uniquely add the spell to her own wizard spell list.
(For example, this DM has always assumed that a creature adds the new spells to the creature's appropriate spell list when the creature succeeds at Researching Original Spells (DMG 198)—as always, bear in mind that researching original spells is vaguely defined, easily abused, and almost entirely at the DM's discretion.)